<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ include file="/common/taglibs.jsp"%>
    <%@ include file="/common/cssAndjs.jsp"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <script type="text/javascript">
 var menulevel =${menulevel};
 function unitformatter(value, rowData) {
	    for (var i = 0; i < menulevel.length; i++) {
	        if (menulevel[i].code == value) {
	            return menulevel[i].name;
	        }
	    }
	}
 
 /* 模态方式打开菜单录入页面 */
 function addTab(){
 	var  iWidth=880; //模态窗口宽度
 	var  iHeight=280;//模态窗口高度
 	var iTop=(window.screen.height-iHeight)/2; 
 	var iLeft=(window.screen.width-iWidth)/2; 

   var param="";
   param = "?operWay=1" ;
   var openStatus = "width=480,height=280,menubar=no,toolbar=no,top="+iTop+",left="+iLeft+",Location=no,scrollbars=no,status=no,modal=yes";
   
   window.open("${ctx}/menu/menuAddorEdit"+param, "", openStatus);
  
 }
 function editTab(){
	 var  iWidth=880; //模态窗口宽度
	 	var  iHeight=280;//模态窗口高度
	 	var iTop=(window.screen.height-iHeight)/2; 
	 	var iLeft=(window.screen.width-iWidth)/2; 

	   var param="";
	   var rows = $("#menuList").datagrid("getSelections");
	      if (rows.length == 0) {
	        $.messager.alert("请选择一条信息","提示");
	        return;
	      }
	      var id = rows[0].id;
		param = "?operWay=2&id="+id ;
	   var openStatus = "width=480,height=280,menubar=no,toolbar=no,top="+iTop+",left="+iLeft+",Location=no,scrollbars=no,status=no,modal=yes";
	   
	   window.open("${ctx}/menu/menuAddorEdit"+param, "", openStatus);
	 
 }
</script>
 <style type="text/css">
    html, body{
        margin:0;padding:0;border:0;width:100%;height:100%;overflow:hidden;
    }    
    </style>
</head>
<body>
    
     <div id="toolbar">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="addTab()">添加</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editTab()">编辑</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-view" plain="true" onclick="viewTab()">查看</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="searchTab()">查询</a>
    </div>
    <table  id="menuList" class="easyui-treegrid" cellpadding="0" cellspacing="0" border="0" 
            data-options="
                url: '${ctx}/menu/getMenus',
                method: 'get',
                rownumbers: true,
                idField: 'id',
                treeField: 'text',
                toolbar: '#toolbar'
            ">
        <thead>
            <tr>
                <th data-options="field:'text'" width="220">Name</th>
                <th data-options="field:'level' "  formatter= "unitformatter"  width="150">菜单等级</th>
                <th data-options="field:'murl'" width="220">菜单地址</th>
                <th data-options="field:'orderid'" width="120">菜单顺序</th>
            </tr>
        </thead>
    </table>
 
</body>
</html>